package xrz.xuanbao.modular.message;

import java.util.Date;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;
import xrz.cuanbao.R;
import xrz.cuanbao.entitys.MessageRecord;
import xrz.cuanbao.utils.DateKit;

public class Adapter_Message extends QuickAdapter<MessageRecord>{

	public Adapter_Message(Context context, int layoutResId) {
		super(context, layoutResId);
	}

	@Override
	protected void convert(BaseAdapterHelper helper, MessageRecord data) {
		helper.getView().setBackgroundResource(R.drawable.selector_message);
		ImageView img_head = helper.getView(R.id.img_head);
		img_head.setImageResource(data.resid);
		TextView tv_name = helper.getView(R.id.tv_name);
		TextView tv_content = helper.getView(R.id.tv_content);
		TextView tv_time = helper.getView(R.id.tv_time);
		tv_name.setText(data.reason);
		tv_content.setText(data.amount);
		if(data.addtime.equals("") || data.addtime.equals("0"))
			tv_time.setText("");
		else
		tv_time.setText(DateKit.friendlyFormat(new Date((Long.parseLong(data.addtime)*1000))));
	}

}
